﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;

/// <summary>
/// Descripción breve de CuotasDA
/// </summary>
public static class CuotasDA
{
    public static DataTable cuotasListar(string afiliadodni)
    {
        MySqlConnection conexion = Conexion.obtConexion();
        DataTable tabla = new DataTable("especialidad");
        string consulta = @"SELECT  `cuotas`.`cuotaid` AS `ID`, `cuotas`.`cuotames` AS `Mes`, `cuotas`.`cuotaano`
                            AS Ano, afiliadodni as dni,  `cuotas`.`cuotamonto` AS `Monto`, `cuotas`.`cuotafechavencim` AS  `Vencimiento`
                            FROM  `cuotas` WHERE  `cuotas`.`cuotapaga` = 'no' AND  `cuotas`.`afiliadodni` =" + afiliadodni;
        MySqlCommand comando = new MySqlCommand(consulta, conexion);
        conexion.Open();
        MySqlDataReader dataReader = comando.ExecuteReader();
        tabla.Load(dataReader, LoadOption.OverwriteChanges);
        conexion.Close();
        return tabla;
    }

    public static bool cuotasRegstrarPago(string cuotaid, string fechadepago)
    {
        MySqlConnection conexion = Conexion.obtConexion();
        DataTable tabla = new DataTable("especialidad");
        string consulta = @"update cuotas set cuotapaga = 'si', cuotafechapago='" + fechadepago + "' where cuotaid=" + cuotaid;
        MySqlCommand comando = new MySqlCommand(consulta, conexion);
        conexion.Open();
        try
        {
            comando.ExecuteReader();
            return true;
        }
        catch {
            return false;
        }
        conexion.Close();
        
    }
}
